/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rdb.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Bich Tran Van
 */
@Entity
@Table(name = "Exams")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Exams.findAll", query = "SELECT e FROM Exams e"),
    @NamedQuery(name = "Exams.findById", query = "SELECT e FROM Exams e WHERE e.id = :id"),
    @NamedQuery(name = "Exams.findByDateCreate", query = "SELECT e FROM Exams e WHERE e.dateCreate = :dateCreate"),
    @NamedQuery(name = "Exams.findByDateStart", query = "SELECT e FROM Exams e WHERE e.dateStart = :dateStart"),
    @NamedQuery(name = "Exams.findByDateEnd", query = "SELECT e FROM Exams e WHERE e.dateEnd = :dateEnd"),
    @NamedQuery(name = "Exams.findByDateReCounting", query = "SELECT e FROM Exams e WHERE e.dateReCounting = :dateReCounting"),
    @NamedQuery(name = "Exams.findByStatus", query = "SELECT e FROM Exams e WHERE e.status = :status")})
public class Exams implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "Id")
    private Integer id;
    @Column(name = "DateCreate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateCreate;
    @Column(name = "DateStart")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateStart;
    @Column(name = "DateEnd")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateEnd;
    @Column(name = "DateReCounting")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateReCounting;
    @Column(name = "status")
    private Integer status;
    @OneToMany(mappedBy = "examId")
    private List<StudentExams> studentExamsList;
    @JoinColumn(name = "SubjectId", referencedColumnName = "Id")
    @ManyToOne
    private Subjects subjectId;
    
    @JoinColumn(name = "assignFac", referencedColumnName = "user_id")
    @ManyToOne
    private Users assignFac;
    
    @Size(max = 255)
    @Column(name = "ExamId")
    private String examId;

    public Exams() {
    }

    public Exams(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDateCreate() {
        return dateCreate;
    }

    public void setDateCreate(Date dateCreate) {
        this.dateCreate = dateCreate;
    }

    public Date getDateStart() {
        return dateStart;
    }

    public void setDateStart(Date dateStart) {
        this.dateStart = dateStart;
    }

    public Date getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(Date dateEnd) {
        this.dateEnd = dateEnd;
    }

    public Date getDateReCounting() {
        return dateReCounting;
    }

    public void setDateReCounting(Date dateReCounting) {
        this.dateReCounting = dateReCounting;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @XmlTransient
    public List<StudentExams> getStudentExamsList() {
        return studentExamsList;
    }

    public void setStudentExamsList(List<StudentExams> studentExamsList) {
        this.studentExamsList = studentExamsList;
    }

    public Users getAssignFac() {
        return assignFac;
    }

    public void setAssignFac(Users assignFac) {
        this.assignFac = assignFac;
    }
    
    public Subjects getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(Subjects subjectId) {
        this.subjectId = subjectId;
    }

    public String getExamId() {
        return examId;
    }

    public void setExamId(String examId) {
        this.examId = examId;
    }

    
    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Exams)) {
            return false;
        }
        Exams other = (Exams) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rdb.entities.Exams[ id=" + id + " ]";
    }
    
}
